package cn.wolfcode.crm.domain;


import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.HashMap;
import java.util.Map;

@Setter
@Getter
@ToString
public class Department {
    private Long id;

    private String name;

    private String sn;

    public String getJson(){
        Map<String,Object> map = new HashMap<>();
        map.put("id",id);
        map.put("name",name);
        map.put("sn",sn);
        //将map转换为json格式数据
        ObjectMapper mapper = new ObjectMapper();
        try {
            String Json = mapper.writeValueAsString(map);
            return Json;
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }
}